<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.infodms.dms.common.Constant" %>
<%@ page import="java.util.Map" %>
<%
	String contextPath = request.getContextPath();
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@taglib uri="/jstl/cout" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<title>经销商维护</title>
<script type="text/javascript"><!--
var dealerLevel=<%=Constant.DEALER_LEVEL_01%>;
function doInit()
{  
   	var dl=<c:out value="${map.DEALER_LEVEL}"/>;
	if(dealerLevel==dl)
	{
		document.getElementById("sJDealerCode").disabled="true";
		document.getElementById("dealerbu").disabled="true";
		document.getElementById("orgCode").disabled="";
		document.getElementById("orgbu").disabled="";
		
	}else
	{
		document.getElementById("sJDealerCode").disabled="";
		document.getElementById("dealerbu").disabled="";
		document.getElementById("orgCode").disabled="true";
		document.getElementById("orgbu").disabled="true";		
	}
	genLocSel('txt1','txt2','txt3','<c:out value="${map.PROVINCE_ID}"/>','<c:out value="${map.CITY_ID}"/>','<c:out value="${map.COUNTIES}"/>'); // 加载省份城市和县
	document.getElementById("priceId").value="${map.PRICE_ID}";
}


// 检验当前修改经销商下是否存在下级经销商，若存在，则不能执行当前操作，并在前台提示错误
function chkDealer(flag) {
	var url = '<%=contextPath%>/sysmng/dealer/DealerInfo/chkDealer.json' ;
	var iDealerId = document.getElementById('DEALER_ID').value ;
	
	makeCall(url, showErr, {dealerId: iDealerId, flag: flag}) ;
}
// 返回检验经销商错误信息
function showErr(json) {
	var dlrLel = document.getElementById('DEALERLEVEL') ;
	var dlrSta = document.getElementById('DEALERSTATUS') ;
	
	if(json.errInfo == 1) {
		if (json.flag == 0) {
			retDlrLel() ;
		}
		if (json.flag == 1) {
			retDlrSta() ;
		}
		MyAlert('经销商信息有误，请确认经销商信息的完整！') ;
	}else if(json.errInfo == 2) {
		// if (json.flag == 0) {
		// 	retDlrLel() ;
		// }
		// if (json.flag == 1) {
		// 	retDlrSta() ;
		//}
		MyAlert('该经销商存在下级经销商，注意修改下级经销商信息！') ;
		changeDealerlevel(dlrLel.value) ;
	} else {
		if (json.flag == 0) {
			changeDealerlevel(dlrLel.value) ;
		}
	}
}

// 若有检验经销商有错误信息，则返回经销商原有级别
function retDlrLel() {
	var dlrLel = document.getElementById('DEALERLEVEL') ;

	if (dlrLel.value != ${map.DEALER_LEVEL}) {
		dlrLel.value = ${map.DEALER_LEVEL} ;
	}
}

// 若有检验经销商有错误信息，则返回原有经销商状态
function retDlrSta() {
	var dlrSta = document.getElementById('DEALERSTATUS') ;

	if (dlrSta.value != ${map.STATUS}) {
		dlrSta.value = ${map.STATUS} ;
	}
}

// 对选择上级经销商是否当前修改经销商验证
function chkDlr() {
	var dlrA = document.getElementById('DEALER_ID') ;
	var dlrB = document.getElementById('sJDealerId') ;
	var dlrCode = document.getElementById('sJDealerCode') ;

	if(dlrA.value == dlrB.value) {
		dlrB.value = "" ;
		dlrCode.value = "" ;

		alert("选择上级经销商不能为当前经销商！") ;
	}
}

//验证输入经销商代码是否已存在
function chkDLRA(dlrCode) {
	dlrId = ${map.DEALER_ID} ;
	url = "<%=contextPath%>/sysmng/dealer/DealerInfo/chkDlr.json" ;
	makeCall(url, printErr, {dlrCode : dlrCode, dlrId : dlrId}) ;
}

function printErr(json) {
	if(json.errInfo == 1) {
		setText("DEALER_CODE") ;
		MyAlert("输入经销商代码已存在，请重新输入") ;
	}
}

function setText(obj,setValue) {
    if(!setValue) {
    	setValue = "" ;
    }
    
	document.getElementById(obj).value = setValue ;
} 
//
--></script>
</head>
<body>
<div class="navigation"><img src="<%=contextPath%>/img/nav.gif" />&nbsp;当前位置： 系统管理 &gt; 经销商管理 &gt;修改经销商</div>
 <form method="post" name = "fm" >
 <input id="COMPANY_ID" name="COMPANY_ID" type="hidden" value="<c:out value="${map.COMPANY_ID}"/>"/>
 <input id="DEALER_ID" name="DEALER_ID" type="hidden" value="<c:out value="${map.DEALER_ID}"/>"/>
 <input type="hidden"  name="sJDealerId"  value="<c:out value="${map.SJDEALERID}"/>"  id="sJDealerId" onpropertychange="chkDlr();" />
 <input type="hidden"  name="orgId"  value="<c:out value="${map.ORG_ID}"/>"  id="orgId" />
    <table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
		  <tr>
		    <td class="table_query_2Col_label_6Letter">经销商代码：</td>
		    
		    <td><input type='text'  class="middle_txt" name="DEALER_CODE"  id="DEALER_CODE" datatype="0,is_name,20"  value="<c:out value="${map.DEALER_CODE}"/>" maxlength="20" onchange="chkDLRA(this.value);"/>
		    </td>
		    <td class="table_query_2Col_label_6Letter">经销商名称：</td>
		    <td>
		    <input type='text'  class="middle_txt" name="DEALER_NAME"  id="DEALER_NAME" datatype="0,is_null,150"  value="<c:out value="${map.DEALER_NAME}"/>" maxlength="150"/>
		    </td>
	      </tr>
	       <tr>
		    <td class="table_query_2Col_label_6Letter">经销商简称：</td>
		    <td>
		    <input type='text'  class="middle_txt" name="SHORT_NAME"  id="SHORT_NAME" datatype="0,is_null,75"  value="<c:out value="${map.DEALER_SHORTNAME}"/>" maxlength="75"/>
		    </td>
		    <td class="table_query_2Col_label_6Letter">经销商等级：</td>
		    <td>
		    <label>
				<script type="text/javascript">
					genSelBoxExp("DEALERLEVEL",<%=Constant.DEALER_LEVEL%>,"<c:out value="${map.DEALER_LEVEL}"/>",'',"short_sel","onchange='chkDealer(0); '","false",'');
				</script>
		   </label>
		    </td>
	      </tr>
	        <tr>
		    <td class="table_query_2Col_label_6Letter">上级组织：</td>
		    <td>
		    <input type="text"  name="orgCode" size="15" value="<c:out value="${map.ORG_CODE}"/>"  id="orgCode" class="middle_txt" readonly="readonly"/>
		    <input name="orgbu"  id="orgbu" type="button" class="mark_btn" onclick="showOrg('orgCode','orgId','false')" value="&hellip;" />
		    </td>
		    <td class="table_query_2Col_label_6Letter">上级经销商：</td>
		    <td>
		    <input type="text"  name="sJDealerCode" size="15" value="<c:out value="${map.SJDEALERCODE}"/>"  id="sJDealerCode" class="middle_txt" readonly="readonly"/>
		    <input name="dealerbu"  id="dealerbu" type="button" class="mark_btn" onclick="showOrgDealer('sJDealerCode','sJDealerId','false','','true')" value="&hellip;" />
		    </td>
	      </tr>
	       <tr>
		    <td class="table_query_2Col_label_6Letter">经销商类型：</td>
		    <td>
		    <label>
				<script type="text/javascript">
					genSelBoxExp("DEALERTYPE",<%=Constant.DEALER_TYPE%>,"<c:out value="${map.DEALER_TYPE}"/>",true,"short_sel","onchange='dealerType(); '","false",'');
				</script>
		   </label>
		    </td>
		    <td class="table_query_2Col_label_6Letter">经销商公司：</td>
		    <td>
		   <input class="middle_txt" id="COMPANY_NAME" style="cursor: pointer;" name="COMPANY_NAME" type="text" value="<c:out value="${map.COMPANY_SHORTNAME}"/>" readonly="readonly"/>
		   <input class="mark_btn" type="button" value="&hellip;" onclick="showCompany('<%=contextPath %>')"/>
		    </td>
	      </tr>
	      <tr id="labour_id" style="display: none">
	       <td class="table_query_2Col_label_6Letter">连锁店作业等级：</td>
		    <td>
		    <label>
				<script type="text/javascript">
					genSelBoxExp("DEALER_LABOUR_CODE",<%=Constant.DEALER_LABOUR_CODE%>,"<c:out value="${map.DEALER_LABOUR_TYPE}"/>",'',"short_sel",'',"false",'');
				</script>
		   </label>
		    </td>
		    <td class="table_query_2Col_label_6Letter">是否为DQV：</td>
		    <td>
		    <label>
		    <%
		    	java.util.Map map=(java.util.Map)request.getAttribute("map");
		    	String IS_DQV=com.infodms.dms.util.CommonUtils.checkNull(map.get("IS_DQV"));
		    	if(IS_DQV.equals("")) IS_DQV=Constant.IF_TYPE_NO.toString();
		    %>
				<script type="text/javascript">
					genSelBoxExp("IS_DQV",<%=Constant.IF_TYPE%>,"<%=IS_DQV%>",false,"short_sel",'',"false",'');
				</script>
		    </label>
		    </td>
	      </tr>
	      
	      <tr id="labour_id2" style="display: none">
	       <td class="table_query_2Col_label_6Letter">结算等级：</td>
		    <td>
		    <label>
				<script type="text/javascript">
					genSelBoxExp("BALANCE_LEVEL",<%=Constant.BALANCE_LEVEL%>,'${map.BALANCE_LEVEL}','true',"short_sel",'',"false",'');
				</script>
		   </label>
		    </td>
		    <td class="table_query_2Col_label_6Letter">开票等级：</td>
		    <td>
		    <label>
				<script type="text/javascript">
					genSelBoxExp("INVOICE_LEVEL",<%=Constant.INVOICE_LEVEL%>,'${map.INVOICE_LEVEL}',true,"short_sel",'',"false",'');
				</script>
		    </label>
		    </td>
	      </tr>
	      
	      <tr>
	      <td class="table_query_2Col_label_6Letter">经销商状态：</td>
	      <td>
	      <label>
				<script type="text/javascript">
					genSelBoxExp("DEALERSTATUS",<%=Constant.STATUS%>,"<c:out value="${map.STATUS}"/>",true,"short_sel","onchange='chkDealer(1); '","false",'');
				</script>
		  </label>
	      </td>
	      <td class="table_query_2Col_label_6Letter">省份：</td>
	      <td><select class="min_sel" id="txt1" name="province" onchange="_genCity(this,'txt2')"></select> </td>
         </tr>
         <tr> 
          <td class="table_query_2Col_label_6Letter">地级市：</td>
	      <td><select class="min_sel" id="txt2" name="city" onchange="_genCity(this,'txt3')"></select></td>  
	      <td class="table_query_2Col_label_6Letter">邮编：</td>
	      <td><input type="text"  class="middle_txt" name="zipCode"  id="zipCode" value="<c:out value="${map.ZIP_CODE}"/>" maxlength="10" datatype="1,is_digit_letter,30" /></td>
	     </tr>
	     <tr>
	      <td class="table_query_2Col_label_6Letter">联系人：</td>
	      <td><input type="text"  class="middle_txt" name="linkMan"  id="linkMan"  datatype="1,is_name,10" value="<c:out value="${map.LINK_MAN}"/>" maxlength="10"/></td>
	      <td class="table_query_2Col_label_6Letter">电话：</td>
	      <td><input type="text"  class="middle_txt" name="phone"  id="phone" datatype="1,is_null,100" value="<c:out value="${map.PHONE}"/>" maxlength="25"/></td> 
	     </tr>
	<tr>
	      <td class="table_query_2Col_label_6Letter">传真：</td>
	      <td><input type="text"  class="middle_txt" name="faxNo"  id="faxNo" value="<c:out value="${map.FAX_NO}"/>"  datatype="1,is_null,50" maxlength="25"/></td>
	      <td class="table_query_2Col_label_6Letter">Email：</td>
	      <td><input type="text"  class="middle_txt" name="email"  id="email" datatype="1,is_email,100" value="<c:out value="${map.EMAIL}"/>" maxlength="100"/></td>
	      </tr>
	<tr>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">经销商评级：</td>
		<td class="table_query_4Col_input" nowrap="nowrap"> 
		<label>
				<script type="text/javascript">
					genSelBoxExp("DEALERCLASS",<%=Constant.DEALER_CLASS_TYPE%>,"<c:out value="${map.DEALER_CLASS}"/>",false,"short_sel",'',"false",'');
				</script>
		</label>
		</td>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">开票单位：</td>
		<td><input type="text"  class="middle_txt" name="erpCode" id="erpCode" datatype="0,is_textarea,20" value="<c:out value="${map.ERP_CODE}"/>" maxlength="20"/></td> 
	</tr>
	<tr>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">税号：</td>
		<td class="table_query_4Col_input" nowrap="nowrap"> 
			<input type="text"  class="middle_txt" id="taxesNo" name="taxesNo" value="${map.TAXES_NO }"  datatype="0,is_textarea,30" />
		</td>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">区/县：</td>
		<td class="table_query_4Col_input" nowrap="nowrap"> <select class="min_sel" id="txt3" name="COUNTIES"></select></td>
	</tr>
	<tr>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">乡：</td>
		<td class="table_query_4Col_input" nowrap="nowrap"> 
			<input type="text"  class="middle_txt" id="TOWNSHIP" name="TOWNSHIP" value="${map.TOWNSHIP}"/>
		</td>
		<td class="table_query_2Col_label_6Letter">法人：</td>
	    <td><input type="text"  class="middle_txt" name="LEGAL"  id="LEGAL" value="${map.LEGAL}"/></td>
	</tr>
	<tr>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">站长电话：</td>
		<td class="table_query_4Col_input" nowrap="nowrap"> 
			<input type="text"  class="middle_txt" id="WEBMASTER_PHONE" name="WEBMASTER_PHONE" value="${map.WEBMASTER_PHONE}"/>
		</td>
		<td class="table_query_2Col_label_6Letter">值班电话：</td>
	    <td><input type="text"  class="middle_txt" name="DUTY_PHONE"  id="DUTY_PHONE" value="${map.DUTY_PHONE}"/></td>
	</tr>
	<tr>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">开户行：</td>
		<td class="table_query_4Col_input" nowrap="nowrap"> 
			<input type="text"  class="middle_txt" id="BANK" name="BANK" value="${map.BANK}"/>
		</td>
		<td class="table_query_2Col_label_6Letter">维修资源：</td>
	    <td>
		<label>
				<script type="text/javascript">
					genSelBoxExp("MAIN_RESOURCES",<%=Constant.MAIN_RESOURCES%>,"${map.MAIN_RESOURCES}",true,"short_sel",'',"false",'');
				</script>
		</label>
		</td>
	</tr>
	<tr>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">行政级别：</td>
		<td class="table_query_4Col_input" nowrap="nowrap"> 
		<label>
				<script type="text/javascript">
					genSelBoxExp("ADMIN_LEVEL",<%=Constant.ADMIN_LEVEL%>,"${map.ADMIN_LEVEL}",true,"short_sel",'',"false",'');
				</script>
		</label>
		</td>
		<td class="table_query_2Col_label_6Letter">形象等级：</td>
	    <td>
		<label>
				<script type="text/javascript">
					genSelBoxExp("IMAGE_LEVEL",<%=Constant.IMAGE_LEVEL%>,"${map.IMAGE_LEVEL}",true,"short_sel",'',"false",'');
				</script>
		</label>
		</td>
	</tr>
	<!-- 
	<tr>
		<td class="table_query_3Col_label_6Letter" nowrap="nowrap">纳税级别：</td>
		<td class="table_query_4Col_input" nowrap="nowrap"> 
		<label>
				<script type="text/javascript">
					genSelBoxExp("TAX_LEVEL",<%=Constant.IMAGE_LEVEL%>,"${map.TAX_LEVEL}",true,"short_sel",'',"false",'');
				</script>
		</label>
		</td>
		<td class="table_query_2Col_label_6Letter"></td>
	    <td></td>
	</tr>
	 -->
	      <tr>
	        <td class="table_query_2Col_label_6Letter">详细地址：</td>
	      	<td><textarea name="address" id="address" cols="40" rows="2" datatype="1,is_textarea,50" ><c:out value="${map.ADDRESS}"/></textarea></td>
	      </tr>
	      <tr>
	        <td class="table_query_2Col_label_6Letter">备注：</td>
	      	<td><textarea name="remark" id="remark" cols="40" rows="2" datatype="1,is_textarea,1000"><c:out value="${map.REMARK}"/></textarea></td>
	      </tr>
     </table> 
     <table class=table_query>
	 <tr>
	 <td>
	<input type="button" value="修改" name="saveBtn" class="normal_btn" onclick="saveDealerInfo();"/>	
	<input type="button" value="返回" name="cancelBtn"  class="normal_btn" onclick="goBack();" />
	<input type="button" value="资金账户同步" name="priceCon"  class="long_btn" onclick="go_Price();" />
	</td>
	</tr>
   </table>
   <br/>
    <table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query" id="businessTable">
     <tr><th colspan="3"><img src="<%=contextPath%>/img/nav.gif" />业务范围列表 <input type="button" value="添加业务范围" name="saveBtn" class="long_btn" onclick="addBusiness();"/></th></tr>
     <tr>
     <th>业务范围代码</th>
     <th>业务范围名称</th>
     <th>操作</th>
     </tr>
     <c:forEach items="${businessList}" var="bl" >
     <tr class="table_list_row1">
     <td><c:out value="${bl.AREA_CODE}"/></td>
     <td><label id="defaultPrice"><c:out value="${bl.AREA_NAME}"/></label></td>
     <td><a href="#" onClick="delBusiness('<c:out value="${bl.RELATION_ID}"/>')" >删除</a></td>
     </tr>
     </c:forEach>
    </table>
    <table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query" id="addressTable">
    </table>
    <br/>
    <table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query" id="businessTable">
     <tr><th colspan="7"><img src="<%=contextPath%>/img/nav.gif" />经销商地址列表  <input type="button" value="添加经销商地址" name="saveBtn" class="long_btn" onclick="addAddress();"/></th></tr>
     <tr>
     <th>地址代码</th>
     <th>地址名称</th>
     <th>联系人</th>
     <th>电话</th>
     <th>备注</th>
     <th>状态</th>
     <th>操作</th>
     </tr>
     <c:forEach items="${addressList}" var="al" >
     <c:if test="${al.STATUS==10011001}">
     <tr class="table_list_row1">
     <td><c:out value="${al.ADD_CODE}"/></td>
     <td><c:out value="${al.ADDRESS}"/></td>
     <td><c:out value="${al.LINK_MAN}"/></td>
     <td><c:out value="${al.TEL}"/></td>
     <td><c:out value="${al.REMARK}"/></td>
     <td><script>document.write(getItemValue(${al.STATUS }));</script></td>
     <td><a href="#" onClick="modifyAdd('<c:out value="${al.ID}"/>')" >修改</a></td>
     </tr>
     </c:if>
     <c:if test="${al.STATUS==10011002}">
     <tr class="table_list_row1">
     <td><FONT color="red"><c:out value="${al.ADD_CODE}"/></FONT></td>
     <td><FONT color="red"><c:out value="${al.ADDRESS}"/></FONT></td>
     <td><FONT color="red"><c:out value="${al.LINK_MAN}"/></FONT></td>
     <td><FONT color="red"><c:out value="${al.TEL}"/></FONT></td>
     <td><FONT color="red"><c:out value="${al.REMARK}"/></FONT></td>
     <td><script>document.write(getItemValue(${al.STATUS }));</script></td>
     <td><a href="#" onClick="modifyAdd('<c:out value="${al.ID}"/>')" >修改</a></td>
     </tr>
     </c:if>
     </c:forEach>
    </table>
    <a name="anchorA"></a>
     <table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query" id="businessTable">
     <tr><th colspan="7"><img src="<%=contextPath%>/img/nav.gif" />使用价格</th></tr>
     <tr>

     <th>价格类型代码</th>
     <th>价格类型描述</th>
     <th>默认价格</th>
     <th>有效开始日期</th>
     <th>有效结束日期</th>
     <th>创建日期</th>
     <th>操作</th>
     </tr>
     <c:forEach items="${types}" var="al">
     <tr class="table_list_row1">
     <td><c:out value="${al.PRICE_CODE}"/></td>
     <td><c:out value="${al.PRICE_DESC}"/></td>
     <td><c:out value="${al.CODE_DESC}"/></td>
     <td><c:out value="${al.START_DATE}"/></td>
     <td><c:out value="${al.END_DATE}"/></td>
     <td><c:out value="${al.CREATE_DATE}"/></td>
     <td><a href="#anchorA" onClick="delPrice('<c:out value="${al.RELATION_ID}"/>')" >[删除]</a>
     <a href="#anchorA" onClick="defaultPrice('<c:out value="${al.RELATION_ID}"/>','<c:out value="${al.PRICE_ID}"/>')" >[设置默认]</a></td>
     </tr>
      </c:forEach>
     <tr>
     <td colspan="4" align="center"><input type="button" value="新增价格" name="saveBtn" class="long_btn" onclick="addPrice();"/></td>
     </tr>
    </table>
</form>

<script type="text/javascript" >

function changeDealerlevel(value)
{
	if(dealerLevel==value)
	{
		document.getElementById("sJDealerCode").disabled="true";
		document.getElementById("dealerbu").disabled="true";
		document.getElementById("orgCode").disabled="";
		document.getElementById("orgbu").disabled="";
		document.getElementById("sJDealerCode").value="";
		document.getElementById("sJDealerId").value="";
		
	}else
	{
		document.getElementById("sJDealerCode").disabled="";
		document.getElementById("dealerbu").disabled="";
		document.getElementById("orgCode").disabled="true";
		document.getElementById("orgbu").disabled="true";
		document.getElementById("orgCode").value="";
		document.getElementById("orgId").value="";		
	}
}

function go_Price(){

		if(confirm("确认同步经销商资金账户,同步完需等待5分钟？"))
		{
			fm.action = '<%=contextPath%>/sysmng/dealer/DealerInfo/modifyDealerPrice.do';
		 	fm.submit();
		}
}

function saveDealerInfo()
{
	var text1=document.getElementById("txt1").value;
	var text2=document.getElementById("txt2").value
	if(text1==""){
			MyAlert('省份输入不能为空！');
			return;
		}
	if(text2==""){
		MyAlert('城市输入不能为空！');
		return;
	}
	var DEALERTYPE=document.getElementById("DEALERTYPE").value;
	var DEALERSTATUS=document.getElementById("DEALERSTATUS").value;
	var DEALERCLASS=document.getElementById("DEALERCLASS").value;
	if(DEALERTYPE==""){
		MyAlert("经销商类型不能为空！");
		return;
		}
	if(DEALERSTATUS==""){
		MyAlert("经销商状态不能为空！");
		return;
	}
	//if(DEALERCLASS==""){
		//MyAlert("经销商评级不能为空！");
		//return;
	//}

	if(DEALERTYPE==<%=Constant.DEALER_TYPE_DWR%>){
		var BALANCE_LEVEL=document.getElementById("BALANCE_LEVEL").value;
		var INVOICE_LEVEL=document.getElementById("INVOICE_LEVEL").value;
		var DEALERLEVEL=document.getElementById("DEALERLEVEL").value;//经销商级别
		if(BALANCE_LEVEL==''){
			MyAlert('请选择结算等级!');
			return;
		}
		if(INVOICE_LEVEL==''){
			MyAlert('请选择开票等级!');
			return;
		}
		if(DEALERLEVEL==<%=Constant.DEALER_LEVEL_01%>){//一级经销商
			if(BALANCE_LEVEL!=<%=Constant.BALANCE_LEVEL_SELF%>){
				MyAlert('一级经销商结算等级必须选择 独立结算!');
				return;
			}
			if(INVOICE_LEVEL!=<%=Constant.INVOICE_LEVEL_SELF%>){
				MyAlert('一级经销商开票等级必须选择 独立开票!');
				return;
			}
			
		}else{//二级经销商
			if(BALANCE_LEVEL==<%=Constant.BALANCE_LEVEL_HIGH%>&&INVOICE_LEVEL==<%=Constant.INVOICE_LEVEL_SELF%>){
				MyAlert('结算等级为上级结算时,不能选择独立开票!');
				return;
			}
		}
	}
	
	var dl=document.getElementById("DEALERLEVEL").value;
	if(dealerLevel==dl)
	{
		var orgId=document.getElementById("orgId").value;
		if(orgId=="")
		{
			alert("请选择上级组织！");
			return;
		}
	}else
	{
		var sjId=document.getElementById("sJDealerId").value;
		if(sjId=="")
		{
			alert("请选择上级经销商！");
			return;	
		}
	}
	var companyId=document.getElementById("COMPANY_ID").value;
	if(companyId=="")
	{
		alert("请选择经销商公司！");
		return;	
	}
	if(submitForm('fm'))
	{
		if(confirm("确认修改经销商信息吗？"))
		{
			fm.action = '<%=contextPath%>/sysmng/dealer/DealerInfo/modifyDealerInfo.do';
		 	fm.submit();
		}
	 }
}
function addBusiness()
{
	var dealerId=document.getElementById("DEALER_ID").value;
	OpenHtmlWindow('<%=contextPath%>/sysmng/dealer/DealerInfo/addBusiness.do?dealerId='+dealerId,600,400);
}

function addPrice()
{
	var dealerId=document.getElementById("DEALER_ID").value;
	OpenHtmlWindow('<%=contextPath%>/sysmng/dealer/DealerInfo/addPrice.do?dealerId='+dealerId,700,500);
}
function addAddress()
{
	var dealerId=document.getElementById("DEALER_ID").value;
	OpenHtmlWindow('<%=contextPath%>/sysmng/dealer/DealerInfo/addAddress.do?dealerId='+dealerId,800,400);
}
function modifyAdd(id)
{
	var dealerId=document.getElementById("DEALER_ID").value;
	OpenHtmlWindow('<%=contextPath%>/sysmng/dealer/DealerInfo/modifyAdd.do?dealerId='+dealerId+'&id='+id,800,400);
}
function delAdd(id)
{
	if(confirm("确认删除该地址吗？"))
	{
		fm.action = '<%=contextPath%>/sysmng/dealer/DealerInfo/delAdd.do?id='+id;
	 	fm.submit();
	}
}
function delPrice(relationId)
{
	if(confirm("确认删除该价格吗？"))
	{
		fm.action = '<%=contextPath%>/sysmng/dealer/DealerInfo/delPrice.do?relationId='+relationId;
	 	fm.submit();
	}
}
function defaultPrice(relationId,priceId)
{
	var dealerId=document.getElementById("DEALER_ID").value;
	OpenHtmlWindow('<%=contextPath%>/sysmng/dealer/DealerInfo/defaultMyPriceView.do?relationId='+relationId+'&priceId='+priceId+'&dealerId='+dealerId,800,400);
	//if(confirm("确认设置当前价格为默认价格？"))
	//{
	// 	fm.submit();
//	}
}
function delBusiness(relationId)
{
	if(confirm("确认删除该经销的业务范围吗？"))
	{
		fm.action = '<%=contextPath%>/sysmng/dealer/DealerInfo/delBusiness.do?relationId='+relationId;
		fm.submit();
	}
 	
}
function parentMonth()
{
	fm.action='<%=contextPath%>/sysmng/dealer/DealerInfo/queryDealerInfoDetail.do';
	fm.submit();
}
function goBack()
{
	fm.action='<%=contextPath%>/sysmng/dealer/DealerInfo/queryDealerInfoInit.do';
	fm.submit();
}
function dealerType(){
	if($('DEALERTYPE').value==<%=Constant.DEALER_TYPE_DWR%>){
		$('labour_id').style.display='';
		$('labour_id2').style.display='';
	}
	else{
		$('labour_id').style.display='none';
		$('labour_id2').style.display='none';
	}
}
dealerType();
</script>

</body>
</html>
